<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.EmployeeTimeListTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <h:outputText escape="false" value="#{bundle.ListEmployeeTimeEmpty}" rendered="#{reportsController.items.rowCount == 0}"/>
                <h:panelGroup rendered="#{reportsController.items.rowCount > 0}">
                    <h:outputText value="#{reportsController.pagination.pageFirstItem + 1}..#{reportsController.pagination.pageLastItem + 1}/#{reportsController.pagination.itemsCount}"/>&nbsp;
                    <h:commandLink action="#{reportsController.previous}" value="#{bundle.Previous} #{reportsController.pagination.pageSize}" rendered="#{reportsController.pagination.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{reportsController.next}" value="#{bundle.Next} #{reportsController.pagination.pageSize}" rendered="#{reportsController.pagination.hasNextPage}"/>&nbsp;
                    <h:dataTable value="#{reportsController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Day"/>
                            </f:facet>
                            <h:outputText value="#{item.day}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </h:column>

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Date"/>
                            </f:facet>
                            <h:outputText value="#{item.date}"/>
                        </h:column>

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Details"/>
                            </f:facet>
                            <h:panelGroup rendered="#{item.timelogs.size()> 0}">
                                <h:dataTable value="#{item.timelogs}" var="tl">
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListTimeLogTitle_date}"/>
                                        </f:facet>
                                        <h:outputText value="#{tl.date}">
                                            <f:convertDateTime pattern="MM/dd/yyyy" />
                                        </h:outputText>
                                    </h:column>

                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListTimeLogTitle_project}"/>
                                        </f:facet>
                                        <h:outputText value="#{tl.project.projectName}"/>
                                    </h:column>

                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListTimeLogTitle_workedHours}"/>
                                        </f:facet>
                                        <h:outputText value="#{tl.workedHours}"/>
                                    </h:column>
                                    
                                   
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="&nbsp;"/>
                                        </f:facet>
                                        <h:commandLink action="#{reportsController.destroyEmployeesReport(tl.tlId)}" value="Delete"/>
                                        <h:outputText value=" "/>
                                        <h:commandLink action="#{reportsController.rejectEmployeesReport(tl.tlId)}" value="Reject"/>
                                    </h:column>
                                </h:dataTable>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Hours"/>
                            </f:facet>
                            <h:outputText value="#{item.hours}"/>
                        </h:column>
                    </h:dataTable>                       
                </h:panelGroup>
                <br />
                <br />
                <h:button value="Back to Home" outcome="/index"  />
            </h:form>
        </ui:define>
    </ui:composition>
</html>